| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 9 | describe('Plugin installer', function () { |
||
| 10 | it('"Plugin.install" Should be a function', function () { |
||
| 11 | should(Plugin.install).be.a.Function() |
||
| 12 | }) |
||
| 13 | }) |
||
| 14 | |||
| 15 | describe('Plugin Installed', function () { |
||
| 16 | it('Plugin Should be installed', function () { |
||
| 17 | const Vue = require('vue').default |
||
| 18 | Vue.use(Plugin) |
||
| 19 | |||
| 20 | assert.property(Vue, 'dialog') |
||
| 21 | }) |
||
| 22 | }) |
||
| 23 | |||
| 24 | describe('Plugin Available', function () { |
||
| 25 | it('"$dialog" Should be a available on the created, mounted hooks', function () { |
||
| 26 | const Vue = require('vue').default |
||
| 27 | Vue.use(Plugin) |
||
| 28 | |||
| 29 | new Vue({ |
||
| 30 | created(){ |
||
| 31 | assert.property(this, '$dialog') |
||
| 32 | }, |
||
| 33 | mounted(){ |
||
| 34 | assert.property(this, '$dialog') |
||
| 35 | }, |
||
| 36 | render(h){ |
||
| 37 | return h('p', {id: 'test'}, 'test') |
||
| 38 | } |
||
| 39 | }).$mount() |
||
| 40 | }) |
||
| 41 | }) |
||
| 42 | |||
| 43 | describe('Plugin Available', function () { |
||
| 44 | it('"$dialog" Should be a available in component methods', function () { |
||
| 45 | const Vue = require('vue').default |
||
| 46 | Vue.use(Plugin) |
||
| 47 | |||
| 48 | let vm = new Vue({ |
||
| 49 | methods: { |
||
| 50 | check(){ |
||
| 51 | assert.property(this, '$dialog') |
||
| 52 | } |
||
| 53 | }, |
||
| 54 | render(h){ |
||
| 55 | return h('p', {id: 'test'}, 'test') |
||
| 56 | } |
||
| 57 | }).$mount() |
||
| 58 | |||
| 59 | vm.check() |
||
| 60 | }) |
||
| 61 | }) |
||
| 62 |